package com.googlecode.publicholiday.config;

import com.googlecode.publicholiday.repository.ImmutablePublicHolidayRepository;
import com.googlecode.publicholiday.repository.MutablePublicHolidayRepository;
import com.googlecode.publicholiday.repository.SpringJdbcImmutablePublicHolidayRepository;
import com.googlecode.publicholiday.repository.SpringJdbcPublicHolidayRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RepositoryConfig {

    @Autowired
    private DataSourceConfig dataSourceConfig;

    @Bean
    public ImmutablePublicHolidayRepository immutablePublicHolidayRepository() {
        return new SpringJdbcImmutablePublicHolidayRepository(dataSourceConfig.dataSource());
    }

    @Bean
    public MutablePublicHolidayRepository mutablePublicHolidayRepository() {
        return new SpringJdbcPublicHolidayRepository(dataSourceConfig.dataSource());
    }
}
